package com.peza.bikelog.common.util;

public class Util {

	private static Util instance;
	
	private Util (){
		
	}
	
	public static Util getInstance(){
		if (instance == null){
			instance = new Util();
		}
		return instance;
	}
	
	public Integer convertToInt(Double input){
		Integer value = 0;
		try {
			value = input.intValue();
		} catch (NumberFormatException e) {
			System.err.println(input + " is not a valid integer.");
		}
		return value;
		
	}
	
	public Integer convertToInt(String input){
		Integer value = 0;
		try {
			value = Integer.parseInt(input);
		} catch (NumberFormatException e) {
			System.err.println(input + " is not a valid integer.");
		}
		return value;
		
	}
	
	
	public Long convertToLong(String input){
		Long value = 0L;
		try {
			value = Long.parseLong(input);
		} catch (NumberFormatException e) {
			System.err.println(input + " is not a valid long.");
		}
		return value;	
	}
	
	public Long convertToFloat(String input){
		Long value = 0L;
		try {
			value = Long.parseLong(input);
		} catch (NumberFormatException e) {
			System.err.println(input + " is not a valid long.");
		}
		return value;	
	}
	
	
	public Boolean convertToBoolean(String input){
		Boolean value = null;
		try {
			value = Boolean.parseBoolean(input);
		} catch (NumberFormatException e) {
			System.err.println(input + " is not a valid boolean.");
		}
		return value;	
	}

	
	
}
